<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
q1:
<input id="q1" type="text" value="123">
q2"
<input id="q2" type="text" value="456">

<input type="button" value="提交" onclick="test()">
</br>
result:
<input id="result" type="text" value="">
</body>
<script>

    function test(){
        var q1 = document.getElementById("q1").value;
        var q2 = document.getElementById("q2").value;
        var json = '{"q1":"' + q1 + '" ,"q2":"'  + q2 + '"}';
        var _url = "http://127.0.0.1:8081/test";
        _xmlhttp = new XMLHttpRequest();
        _xmlhttp.open("POST", _url, false);
        _xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        _xmlhttp.send("json=" + json);
        if (_xmlhttp.readyState == 4 && _xmlhttp.status == 200) {
            var obj = eval("(" + _xmlhttp.responseText + ")");
            console.log(obj.data)
            document.getElementById("result").value = obj.data
        } else {
        }
    }

</script>
</html>